{% extends 'base.html' %}
{% load static %}
{% block title %}执行任务{% endblock %}
{% block content %}
    <div>
        <ul class="nav nav-tabs">
            <li class="active"><a href="#host" data-toggle="tab">主机</a></li>
            <li><a href="#hostgroup" data-toggle="tab">主机组</a></li>
        </ul>
        <form action="" method="post" style="padding-top: 10px">
            {% csrf_token %}
            <div class="tab-content">
                <div class="tab-pane active fade in form-group" id="host">
                    <select name="ip" class="form-control">
                        <option value="">无</option>
                        {% for host in hosts %}
                            <option value="{{ host.ipaddr }}">{{ host.hostname }}: {{ host.ipaddr }}</option>
                        {% endfor %}
                    </select>
                </div>
                <div class="tab-pane fade form-group" id="hostgroup">
                    <select name="group" class="form-control">
                        <option value="">无</option>
                        {% for group in groups %}
                            <option value="{{ group.group_name }}">{{ group.group_name }}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
            <table class="table table-bordered table-hover">
                <tr class="info">
                    <td>模块</td>
                    <td>参数</td>
                </tr>
                {% for module in modules %}
                    <tr>
                        <td>
                            <div class="radio">
                                <label><input type="radio" name="module" value="{{ module.module_name }}">{{ module.module_name }}</label>
                            </div>
                        </td>
                        <td>
                            {% for arg in module.argument_set.all %}
                                <div class="radio">
                                    <label><input type="radio" name="arg" value="{{ arg.argument_text }}">{{ arg.argument_text }}</label>
                                </div>
                            {% endfor %}
                        </td>
                    </tr>
                {% endfor %}
            </table>
            <div class="form-group text-center">
                <input class="btn btn-primary" type="submit" value="执 行">
            </div>
        </form>
    </div>
{% endblock %}
